from urllib.request import urlopen
from bs4 import BeautifulSoup
import re

html = urlopen("http://www.pythonscraping.com/pages/page3.html")
bsObj = BeautifulSoup(html,"html.parser")

for value in bsObj.findAll("img",{"src":re.compile("\.\.\/img\/gifts\/img[0-9]*\.jpg")}):
    print(value["src"])
    print(value,type(value),value.attrs,len(value.attrs))
    for key,value1 in value.attrs.items():
        print(key,value1)

print('*' * 20)

for value in bsObj.findAll(lambda x: x.get("src") != None and re.match("\.\.\/img\/gifts\/img[0-9]*\.jpg",x["src"])):
    print(value["src"])